<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var r = new XMLHttpRequest()
    r.open('GET', '/login', true)
    r.onreadystatechange = function () {
        console.log('state change', r)
    }
    r.send()

    var r = new XMLHttpRequest()
    r.open('POST', '/login', true)
    r.setRequestHeader('Content-Type', 'application/json')
    r.onreadystatechange = function () {
        if (r.readyState === 4) {
            console.log('state change', r, r.status, r.response)
            var response = JSON.parse(r.response)
            console.log('response', response)
        } else {
            console.log('change')
        }
    }

    var account = {
        username: 'juran',
        password: '123',
    }

    var data = JSON.stringify(account)
    r.send(data)

    //封装成一个函数
    var ajax = function (method, path, headers, data, responseCallback) {

    }
</script>

</body>
</html>